package io.renren.modules.bike.service.impl;

import com.alipay.easysdk.factory.Factory;
import com.alipay.easysdk.payment.page.models.AlipayTradePagePayResponse;
import io.renren.modules.bike.entity.MoneyEntity;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service
public class PayService {

    @Value("${alipay.returnUrl}")
    private String returnUrl;

    /**
     * 下单支付
     *
     * @return 结果
     * @throws Exception 异常
     */
    public Object pay(MoneyEntity money) throws Exception {
        System.out.println(returnUrl);
        AlipayTradePagePayResponse response = Factory.Payment.Page().pay(
                "余额充值",
                UUID.randomUUID().toString().substring(0, 10),
                money.getMoney(),
                returnUrl);
        return response.body;
    }
}
